home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Text / Edit / GoldED-Demo / installdata / golded / developer / scanner / examples / defines / define.c
Encoding:
C/C++ Source or Header  |  1999-12-03  |  1.7 KB  |  66 lines

  1. /* -----------------------------------------------------------------------------
  2.  
  3.   Scan handler looking for #defines.
  4.   
  5.   Scan handlers are plain functions (loadSeg()'ed): no standard C startup
  6.   code and no library calls permitted. We have to put string constants into
  7.   the code segment (DICE compiler: option -ms1).
  8.  
  9.   DICE:
  10.   
  11.   dcc define.c -// -l0 -md -mRR -o golded:etc/scanner/defines
  12.  
  13.   ------------------------------------------------------------------------------
  14. */
  15.  
  16. #include <exec/types.h>
  17.  
  18. #define UPPER(a) ((a) & 95)
  19.  
  20. ULONG
  21. ScanHandlerGuide(__D0 ULONG len, __A0 char **text, __A1 ULONG *line)
  22. {
  23.     const char *version = "$VER: Define 1.3 (" __COMMODORE_DATE__ ")";
  24.  
  25.     if (**text == '#') {
  26.  
  27.         if (len > 8) {
  28.  
  29.             UBYTE *next = *text + 1;
  30.  
  31.             if (UPPER(*next++) == 'D') {
  32.  
  33.                 if (UPPER(*next++) == 'E') {
  34.  
  35.                     if (UPPER(*next++) == 'F') {
  36.  
  37.                         if (UPPER(*next++) == 'I') {
  38.  
  39.                             if (UPPER(*next++) == 'N') {
  40.  
  41.                                 if (UPPER(*next++) == 'E') {
  42.  
  43.                                     if (*next++ == ' ') {
  44.  
  45.                                         UWORD letters = 0;
  46.  
  47.                                         for (len -= 8; (*next == 32) && len; --len)
  48.                                             ++next;
  49.  
  50.                                         for (*text = next; len && (*next++ != ' '); --len)
  51.                                             ++letters;
  52.  
  53.                                         return(letters);
  54.                                     }
  55.                                 }
  56.                             }
  57.                         }
  58.                     }
  59.                 }
  60.             }
  61.         }
  62.     }
  63.  
  64.     return(FALSE);
  65. }
  66.